home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / ServerList.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  2.3 KB  |  69 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import java.util.Vector;
  7. import symjava.sql.SQLException;
  8.  
  9. public class ServerList extends ServerObject {
  10.    Vector _obj;
  11.  
  12.    ServerList(Vector obj) {
  13.       this._obj = obj;
  14.    }
  15.  
  16.    ServerList() {
  17.       this._obj = new Vector();
  18.    }
  19.  
  20.    public Vector getObjVector() {
  21.       return this._obj;
  22.    }
  23.  
  24.    public Vector toStringVector() {
  25.       Vector v = new Vector();
  26.  
  27.       for(int i = 0; i < this._obj.size(); ++i) {
  28.          NetString s = (NetString)this._obj.elementAt(i);
  29.          v.addElement(new String(s.getString()));
  30.       }
  31.  
  32.       return v;
  33.    }
  34.  
  35.    int getType() {
  36.       return 54;
  37.    }
  38.  
  39.    void read(DataInputStream in) throws SQLException, IOException, ErrorException {
  40.       in.readShort();
  41.       this._obj = new Vector();
  42.  
  43.       while(true) {
  44.          ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  45.          if (obj.getType() == 50) {
  46.             return;
  47.          }
  48.  
  49.          if (obj.getType() == 68) {
  50.             ((ServerObject)this).onObjectError(obj);
  51.          }
  52.  
  53.          this._obj.addElement(obj);
  54.       }
  55.    }
  56.  
  57.    void write(DataOutputStream out) throws IOException {
  58.       out.writeByte(this.getType());
  59.       out.writeShort(0);
  60.  
  61.       for(int i = 0; i < this._obj.size(); ++i) {
  62.          ((ServerObject)this._obj.elementAt(i)).write(out);
  63.       }
  64.  
  65.       EOT eot = new EOT();
  66.       eot.write(out);
  67.    }
  68. }
  69.